function i=getindex(x,value)
I=length(x);
left=1; right=I;
while (right-left>1)
    mid=floor((right+left)/2);
    if (x(mid)>value)
        right=mid;
    else
        left=mid;
    end
end
i=left;